App({
    onLaunch: function onLaunch() {
        // wx.request({
        //     url: 'http://localhost:8080/wxAppletContact/contactIsRegistered',
        //     data: {
        //         openId: this.globalData.openId
        //     },
        //     method: 'POST',
        //     header: {
        //         'content-type': 'application/json'
        //     },
        //     complete: function complete(res) {
        //         if (res.statusCode == 200) {
        //             if (res.data.flag) {
        //                 console.log(res.data.contactId)                        
        //                 wx.redirectTo({
        //                     url: 'pages/contact/login/login'
        //                 });
        //             } else {
        //                 wx.redirectTo({
        //                     url: 'pages/contact/register/register'
        //                 });
        //             }
        //         } else {
        //             console.log("请求失败请稍后重试！");
        //         }
        //     }
        // });
    },
    getCity: function getCity() {
        var that = this;
        wx.request({
            url: 'http://localhost:8080/wxAppletOpportunity/getCityList',
            data: {},
            method: 'POST',
            header: {
                'content-type': 'application/json'
            },
            success: function success(res) {
                var cityListTemp = [];
                var districtListTemp = [];
                for (var i = 0; i < res.data.length; i++) {
                    cityListTemp[i] = res.data[i].name;
                    districtListTemp[i] = res.data[i].districts;
                }
                var defaultDistricts = districtListTemp[0];
                var defaultDistrictsName = [];
                for (var i = 0; i < defaultDistricts.length; i++) {
                    defaultDistrictsName[i] = defaultDistricts[i].name;
                }
                that.setData({
                    cityList: cityListTemp,
                    districtList: defaultDistrictsName,
                    list: districtListTemp
                });
            }
        });
    },
    getOpenId: function getOpenId() {
        var that = this;
        wx.login({
            success: function success(res) {
                wx.request({
                    url: 'http://localhost:8080/wxAppletContact/getOpenId',
                    data: {
                        code: res.code
                    },
                    method: 'POST',
                    header: {
                        'content-type': 'application/json'
                    },
                    success: function success(res) {
                        that.setData({
                            openId: "openId"
                        });
                    }
                });
            }
        });
    },
    globalData: {
        userInfo: null,
        cityList: [],
        list: [],
        openId: "123456",
        contactId: ''
    },
    onShow: function onShow() {
        
    }
});